#include <stdio.h>
#include <stdlib.h>

#include <unistd.h>
#include <libgen.h>

#include <string.h>
#include <pthread.h>

#include "storage/record_manager.h"
#include "state/state.h"

pthread_t thread_listen;

void proc_listen()
{
    sleep(10);
    while(1)
    {
            sleep(1);
        //state = get_sys_state();
        if(get_poweroff())
        {

            printf("rec power off\r\n");

            sleep(10);
            flushAllData();
            printf("sytstem poweroff\n");
            system("halt\n");
            exit(0);
        }
    }
}

void start_listen()
{
    pthread_create(&thread_listen, NULL, proc_listen, NULL);
}
